package com.hnx.admin.aurora.core.permission;

import com.hnx.admin.aurora.security.api.PermissionValidator;
import com.hnx.admin.aurora.security.utils.SecurityUtil;
import com.hnx.admin.aurora.system.domain.vo.user.entity.UserDetailVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.Objects;

/*
创建人： 倔强的头发
创建时间：2025/6/17
功能描述:

*/
@Service
@RequiredArgsConstructor
public class PermissionValidatorImpl implements PermissionValidator {
    @Override
    public boolean hasPermi(String permission) {
        UserDetailVO loginUser = (UserDetailVO) SecurityUtil.getPrincipal();
        if (Objects.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermission()))
        {
            return false;
        }
        return hasPermissions(loginUser.getPermission(), permission);
    }
}
